<?php
/*
 *author:Yangligao
 *Date:2013-9-28
 */
require '../../Config.php';

$flag = $_GET['flag'];

if($flag == 'display'){
	
	$smarty->display('Admin/AdvM/advinsert.html');
}else if($flag == 'advinsert'){
	unset($_POST['x']);
	unset($_POST['y']);
	
	$_POST['adv_addtime'] = time();

	$timeStr = $_POST['year']."-".$_POST['month']."-".$_POST['day'];
	
	$_POST['adv_endtime'] = strtotime($timeStr);
	unset($_POST['year']);
	unset($_POST['month']);
	unset($_POST['day']);

	$upload = new Upload();
	$picPath = $upload->savePic("../Upload/adv");
	$_POST['adv_pic'] = $picPath;
	$advModel = new AdvModel();
	
	$res = $advModel->adv_insert($_POST) ;
	if($res){
		jump('操作成功！', $_SERVER['HTTP_REFERER']);
	}else{
		alertInfo('操作失败！', $_SERVER['HTTP_REFERER']);
	}
}
?>
